package hu;

import java.util.*;

public class lisp_hu {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        StringBuilder dd = new StringBuilder();
        for (int i = 0; i < str.length() - 1; i++) {
            dd.append(str.charAt(i));
            if(str.charAt(i) == '('){
                dd.append(" ");
            }
            if(str.charAt(i + 1) == ')'){
                dd.append(" ");
            }
        }
        dd.append(str.charAt(str.length() - 1));
        String ss = dd.toString();
        System.out.println(ss);
        String[] s1 = ss.split(" ");
        Deque<String> stack = new ArrayDeque<>();
        for (String s : s1) {
            if (s.equals(")")) {
                int a = Integer.parseInt(stack.pop());
                int b = Integer.parseInt(stack.pop());
                String c = stack.pop();
                stack.pop();
                if (c.equals("add")) {
                    stack.push(String.valueOf(a + b));
                } else if (c.equals("sub")) {
                    stack.push(String.valueOf(b - a));
                } else if (c.equals("mul")) {
                    stack.push(String.valueOf(b * a));
                } else if (c.equals("div")) {
                    if (a == 0) {
                        System.out.println("error");
                        return;
                    }
                    stack.push(String.valueOf(b / a));
                }
            } else
                stack.push(s);
        }
        System.out.println(stack.pop());
    }
}
/*
(sub (mul 2 4) (div 9 3))

(div 12 (sub 45 45))

 */